package com.make.house.api.utils;

/**
 * Created by yanglinlong on 17/12/20.
 */
public class NumberUtils {

    public static long toLong(String str) {
        return toLong(str, 0L);
    }

    public static long toLong(String str, long defaultValue) {
        if(str == null) {
            return defaultValue;
        } else {
            try {
                return Long.parseLong(str);
            } catch (NumberFormatException var4) {
                return defaultValue;
            }
        }
    }


    public static int toInt(String str){
        return toInt(str, 0);
    }

    public static int toInt(String str, int defaultValue){
        if (StringUtils.isEmpty(str)){
            return defaultValue;
        } else {
            try {
                return Integer.parseInt(str);
            }catch (Exception e){
                return defaultValue;
            }
        }
    }

}
